import { defineStore } from "pinia"
import axios from "axios" // 整体暴露
import { nanoid } from "nanoid" // 分别暴露,用{}

// const uri = 'https://api.lovelive.tools/api/SweetNothings'

export const useTalkStore = defineStore("talk", {
  actions: {
    async getATalk() {
      let result = await axios.get(
        "http://localhost:5173/api/api/SweetNothings"
      )
      const obj = { id: nanoid(), title: result.data }
      this.talkList.unshift(obj)
    },
  },
  state() {
    return {
      talkList: [
        { id: "1", title: "t1" },
        { id: "2", title: "t2" },
        { id: "3", title: "t3" },
      ],
    }
  },
})
